<template>
  <div>
    <van-nav-bar left-arrow style="background: blue">
      <template #left>
        <van-icon name="arrow-left" color="#fff" size="20" />
      </template> 
      <template #title>
        <span style="color: #fff">消息详情</span>
      </template>
    </van-nav-bar>

    <div class="detail">
      <div class="headers">
        <div class="headers_left">
          <div>{{ detail.title }}</div>
          <span class="user">发布人:{{ detail.sourceName }}</span>
        </div>
        <div class="headers_right">{{ detail.createTime }}</div>
      </div>
      <div class="foots">{{ detail.msgDate }}</div>
    </div>
  </div>
</template>

<script>
import { getNewCenterDetail, getNewCenterDetailReaded } from "@/request/api";
export default {
  data() {
    return {
      detail: {},
    };
  },
  created() {
    console.log("路由", this.$route.query);
    getNewCenterDetail({
      id: this.$route.query.id,
    }).then((res) => {
      console.log(res);
      if (res.errCode == 0) {
        this.detail = res.data;
        // 表单请求的传参方式，需要FormData()
        var formdata = new FormData();
        // 通过append 传入键值对
        formdata.append("id", this.$route.query.id);
        getNewCenterDetailReaded(formdata);
      }
    });
  },
};
</script>

<style>
.detail {
  margin-top: 0.8rem;
  padding: 0.8rem;
  background: #fff;
}
.headers {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user,
.headers_right {
  font-size: 0.9rem;
  color: #999;
}
.foots {
  margin-top: 1rem;
}
</style>